import config from './config'


// 发送ajax请求
export default (url, data = {}, method = 'GET') => {
  return new Promise((resolve, reject) => {
    uni.showLoading({
      title: '加载中'
    });

    uni.request({
      url: config.host + url,
      data,
      method,
      success: (res) => {
        // console.log('请求成功', res);
        uni.hideLoading();
       
        resolve(res.data)
      },
      fail: (err) => {
        uni.hideLoading();
        // console.log('请求失败', err);
        reject(err)
      }
    })
  })
}